//
// Created by xgz on 10/15/21.
//

#include "mutex.hpp"

Monitor::Monitor() {
    pthread_mutex_init(_startThread_lock, NULL);
    pthread_cond_init(_cond, NULL);
}

void Monitor::lock() {
    pthread_mutex_lock(_startThread_lock);
}

void Monitor::unlock() {
    pthread_mutex_unlock(_startThread_lock);
}

void Monitor::notify() {
    pthread_cond_signal(_cond);
}

void Monitor::wait() {
    pthread_cond_wait(_cond, _startThread_lock);
}
